package com.yicheng.statistics.actor

import akka.actor.ActorLogging
import akka.actor.Actor
import com.yicheng.statistics.actor.analysis.TiredStop
import com.yicheng.statistics.actor.analysis.OverSpeedStop
import com.yicheng.statistics.actor.analysis.MileageStop
import com.yicheng.statistics.actor.analysis.BatteryAlarmStop
import com.yicheng.statistics.actor.analysis.AreaStop
import java.util.concurrent.CountDownLatch

class DaemonActor extends Actor with ActorLogging{
  
  override def receive: Receive = {
    case TiredStop =>
      log.info("TiredStop recive")
      stopSystem()
    case OverSpeedStop =>
      log.info("OverSpeedStop recive")
      stopSystem()
    case MileageStop =>
      log.info("MileageStop recive")
      stopSystem()
    case BatteryAlarmStop =>
      log.info("BatteryAlarmStop recive")
      stopSystem()
    case AreaStop =>
      log.info("AreaStop recive")
      stopSystem()
    case _ =>
      
  }
  var count:Int = 5
  def stopSystem(){
    count = count -1
    if(count == 0){
      context.system.terminate()
      System.exit(0)
    }
  }
}